#include <bits/stdc++.h>

using namespace std;

char pic [505][505];
int dis[600][600];

struct Node
{
    int x, y;
    int dis;
};

deque<Node> dq;

int main()
{
    int N,M;
    cin >> N >> M;
    memset(pic, -1, sizeof(pic));

    for(int j = 1; j <= N; j++)
    {
        for(int i = 1; i <= M; i++)
        {
            char temp;
            long now = (M + 1)*(j - 1) + i;
            if(temp == '/')
            {
                pic[j][i] = 1;
            }else if(temp == '\\')
            {
                pic[j][i] = 2;
            }
        }
    }

    Node now;
    now.dis = 0;
    now.x = 1;
    now.y = 1;
    dq.push_front(now);

    int judge = 0;

    while(!dq.empty())
    {
        now = dq.front();
        dq.pop_front();

        Node pts[4];
        pts[0].x = now.x - 1, pts[0].y = now.y - 1;
        pts[1].x = now.x - 1, pts[1].y = now.y + 1;
        pts[2].x = now.x + 1, pts[2].y = now.y + 1;
        pts[3].x = now.x + 1, pts[3].y = now.y - 1;

        if(now.x == 1 && now.y == 1)
        {
            dis[now.x][now.y] = now.dis;
            if(pic[now.x][now.y] == 1)
            {
                pts[2].dis = now.dis + 1;
                dq.push_back(pts[2]);
            }else{
                pts[2].dis = now.dis;
                dq.push_front(pts[2]);
            }
        }else if((now.x == 1 && now.y == N+1) || (now.y == 1 && now.x == M+1))
            continue;
        else if(now.x == M + 1 && now.y == N+1)
        {
            cout<<now.dis;
            judge = 1;
            break;
        }else{
            if(pic[now.x][now.y] == 1)
            {
                
            }
        }

    }
}